package org.jeecg.modules.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.system.entity.Notice;
import org.jeecg.modules.system.vo.JournalVO;
import org.jeecg.modules.system.vo.ReportWeekPlanVO;
import org.jeecg.modules.system.vo.ReportWeekVO;
import org.jeecg.modules.system.vo.SystemMsgRequestVO;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description: 推送
 * @Author: jeecg-boot
 * @Date:   2020-02-23
 * @Version: V1.0
 */
@Repository
public interface NoticeMapper extends BaseMapper<Notice> {

    @Select("select COUNT(a.field3) as field7,a.* from sys_notice as a  " +
            " where a.del_flag = '0' AND (status = '0' OR status = '99') AND a.target_user_id = #{userId}" +
            " AND a.field3 is not NULL GROUP BY field3")
    List<Notice> findUnReads(@Param("userId") String userId);

    @Select("select a.* from sys_notice as a " +
            " where a.del_flag = '0'  AND a.target_user_id =  #{userId} AND a.field3 is not NULL " +
            " GROUP BY field3 ")
    List<Notice> findAllReads(@Param("userId") String userId);

    Integer findUnreadsByType(@Param("userId") String userId, @Param("msgType") String msgType);

    JournalVO getJournalById(@Param("journalId") String journalId);

    ReportWeekVO getReportWeekById(@Param("reportWeekId") String reportWeekId);

    List<Notice> selectSqlList(Page<Notice> page, @Param("msgRequestVO") SystemMsgRequestVO msgRequestVO);

    List<ReportWeekPlanVO> getReportWeekPlanByUserId(@Param("reportWeek") ReportWeekVO reportWeek);

    List<ReportWeekPlanVO> getReportWeekPlanById(@Param("id") String id);
}
